import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialUniversalCodeVO, MaterialUniversalCodeForm, MaterialUniversalCodeQuery } from '@/api/material/materialUniversalCode/types';

/**
 * 查询物料通用码列表
 * @param query
 * @returns {*}
 */

export const listMaterialUniversalCode = (query?: MaterialUniversalCodeQuery): AxiosPromise<MaterialUniversalCodeVO[]> => {
  return request({
    url: '/material/materialUniversalCode/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料通用码详细
 * @param id
 */
export const getMaterialUniversalCode = (id: string | number): AxiosPromise<MaterialUniversalCodeVO> => {
  return request({
    url: '/material/materialUniversalCode/' + id,
    method: 'get'
  });
};

/**
 * 新增物料通用码
 * @param data
 */
export const addMaterialUniversalCode = (data: MaterialUniversalCodeForm) => {
  return request({
    url: '/material/materialUniversalCode',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料通用码
 * @param data
 */
export const updateMaterialUniversalCode = (data: MaterialUniversalCodeForm) => {
  return request({
    url: '/material/materialUniversalCode',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料通用码
 * @param id
 */
export const delMaterialUniversalCode = (id: string | number | Array<string | number>) => {
  return request({
    url: '/material/materialUniversalCode/' + id,
    method: 'delete'
  });
};
